/*
 * @Author: ChunLai
 * @Date: 2022-06-16 16:53:10
 * @LastEditTime: 2025-11-18 17:43:14
 * @Description: 投保服务 --- 管理公共组件的公共状态 已使用
 * @FilePath: \01.latest-short-insure\src\store\modules\common.js
 */
const state = {
  // 手机验证码弹窗
  smsPopShow: false,
  smsCode: '',
  // 手机验证码弹窗 - end
  // 字段说明弹窗
  filedDescLabel: '',
  filedDescCon: '',
  filedDescType: 'text',
  noticeAbnormal: false, // 告知选'是'
};
const getters = {
  smsPopShow: (state) => state.smsPopShow,
  smsCode: (state) => state.smsCode,
  filedDescLabel: (state) => state.filedDescLabel,
  filedDescCon: (state) => state.filedDescCon,
  filedDescType: (state) => state.filedDescType,
  noticeAbnormal: (state) => state.noticeAbnormal,
};
const mutations = {
  SET_STATE_FIELD(state, payload) {
    Object.assign(state, payload);
  },
  CLOSE_FIELD_MEAN(state) {
    state.filedDescCon = "";
  },
  SET_FIELD_MEAN_CONT(state, payload) {
    state.filedDescType = 'text';
    state.filedDescLabel = payload.label;
    state.filedDescCon = payload.desc;
    if (payload.type) {
      state.filedDescType = payload.type;
    }
  },
};
const actions = {
  // 监测告知是否选'是'
  checkNoticeStatus({ state }, datas) {
    if (datas.length === 0) return (state.noticeAbnormal = false);
    const len = datas.length;
    for (let i = 0; i < len; i++) {
      const item = datas[i];
      if (item.impartYesOrNo == 'Y' && item.impartRemark) {
        state.noticeAbnormal = true;
        break;
      }
    }
  },
};

export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions,
};
